program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
pelement=^element;
element=record
  value:integer;
  next:pelement;
end;
var
head:pelement;
i,a:integer;
mass:array of integer;
function dfb(var head:pelement) : Integer;
  var tmp:pelement ;
  begin

        tmp:=head^.next^.next^.next^.next^.next;
        head:=head^.next^.next^.next^.next^.next^.next;
        dfb:= tmp^.value;
        dispose(tmp);

  end;
procedure PL(head:pelement);
var current:pelement;
begin
  current:=head;
  while(current<>nil) do
    begin
      writeln(current^.value);
      current:=current^.next;
    end;
end;
procedure Atb(var head:pelement; num:integer);
var tmp:pelement;
begin
  tmp:=head;
  new(head);
  head^.value:=num;
  head^.next:=tmp;
end;
begin
  for i:=0 to a-1 do
    readln(mass[i]);
  for i:=0 to 7 do
    Atb(mass[i]);
  dfb(head^.next^.next^.next^.next^.next);
  PL;

Readln;


end.

 